package aspects;
 
import java.util.HashMap;
import annotations.*;


public aspect ContadorLlamadasAspect pertarget(monitoredCall(Object)) {
	public HashMap<String, Integer> contador = new HashMap<String, Integer>() ;
	
	pointcut monitoredCall(Object target) : execution(@Monitored public * *(..)) && target(target);
	
	after(Object target) : monitoredCall(target){
		String methodCall = thisJoinPoint.getSignature().getName();
		 if(contador.get(methodCall)==null){
			 contador.put(methodCall, 1);
		 }else{
			 contador.put(methodCall, contador.get(methodCall)+1);
		 }
		}
	
	public int llamadosDe(String metodo){
		return contador.get(metodo);
	}
	
}
